<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
<!--          <a-col :span="24">-->
<!--            <a-form-model-item label="井id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jingId">-->
<!--              <a-input v-model="model.jingId" placeholder="请输入井id"  ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
          <a-col :span="24">
            <a-form-model-item label="井名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jm">
              <a-input v-model="model.jm" placeholder="请输入井名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="施工段长" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sgdc">
              <a-input v-model="model.sgdc" placeholder="请输入施工段长"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="施工段数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sgds">
              <a-input v-model="model.sgds" placeholder="请输入施工段数"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="滑溜水" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hls">
              <a-input v-model="model.hls" placeholder="请输入滑溜水"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="胶联液" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jly">
              <a-input v-model="model.jly" placeholder="请输入胶联液"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="线性胶" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xxj">
              <a-input v-model="model.xxj" placeholder="请输入线性胶"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="70/140石英砂" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sys70">
              <a-input v-model="model.sys70" placeholder="请输入70/140石英砂"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="40/70石英砂" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sys40">
              <a-input v-model="model.sys40" placeholder="请输入40/70石英砂"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="加沙强度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jsqd">
              <a-input v-model="model.jsqd" placeholder="请输入加沙强度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="排量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pl">
              <a-input v-model="model.pl" placeholder="请输入排量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="测试产量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cspl">
              <a-input v-model="model.cspl" placeholder="请输入测试产量"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'YtsjLjsgcsForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/YtsjLjsgcs/ytsjLjsgcs/add",
          edit: "/YtsjLjsgcs/ytsjLjsgcs/edit",
          queryById: "/YtsjLjsgcs/ytsjLjsgcs/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>